__author__ = 'Winter'

import sys

sys.path.append('/Users/Winter/develop/PythonLearning/DataType/')
# Filename: dataStructure.py
# !/usr/bin/python

list1 = [1, 2, 3]

list2 = [4, 5]

list1.extend(list2)

print(list1)

list1.append(2)

print(list1)

list1.insert(0, 12)

print(list1)

list1.remove(3)

print(list1)

list1.pop(2)

print(list1)

print(list1.index(2))

print(list1.count(2))
list1.sort()
print(list1)

from collections import deque

queue = deque(['1', '2', '3'])

queue.append('4')
queue.appendleft('0')
print(queue)

queue.popleft()
print(queue)

vect = [2, 3, 4]
# vect = [2*x for x in vect]
vect = [x ** 2 for x in vect if x < 5]
print(vect)

vert1 = [1, 2, 4]
vert2 = [4, 3, 1]

vect3 = [x + y for x in vert1 for y in vert2]
print(vect3)

vect4 = [vert1[i] * vert2[i] for i in range(len(vert1))]
print(vect4)

for i in range(2, 10):
    print(i)

vect = [str(round(i / 2.215, y)) for i in vect for y in range(1, 4)]
print(vect)

matrix = [
    [1, 2, 3, 4],
    [5, 6, 7, 8],
    [9, 10, 11, 12]
]

matrix = [[row[i] for row in matrix] for i in range(4)]
print(matrix)

list4 = [1, 2, 3, 3, 4, 5]

del list4[0]
print(list4)
del list4[1:3]
print(list4)

del list4[:]
print(list4)

del list4

tup = (1, 2, 3, 4, 5)
print(tup)

tup2 = tup, (6, 7)
print(tup2)

set1 = ()
set2 = {1}

dic1 = {}

set2 = set('abcdefqefaferqaf')

set3 = set('aewfeioofqofj;adfoweifw')

print(set2 - set3)
print(set2 | set3)

set4 = set3 | set2

print(set2 & set3)

print(set2 ^ set3)

a = {x for x in 'aefewoifowf' if x not in 'abc'}
print(a)

dic1 = {'joy': 1234, 'boy': 2324, 'hio': 1233}
print(dic1)

print(dic1['joy'])

dic1['eio'] = 3990

print(dic1)

del dic1['joy']

print(dic1)

print(list(dic1.values()))

print(list(dic1.keys()))

print(sorted(dic1.values()))

print(1233 in dic1.values())

dic2 = dict([('a', 1), ('b', 2)])
print(dic2)

knights = {'Jom': 'brave', 'Green': 'pure'}

for k, v in knights.items():
    print(k, v)

for i, v in enumerate(knights.values()):
    print(i, v)

questionList = ['name', 'quest', 'favourite color']
answerList = ['lanslot', 'the holy grail', 'blue']

for q, a in zip(questionList, answerList):
    print('what\'s your {0} ? It is {1}'.format(q, a))

for i in reversed(questionList):
    print(i)

for i in sorted(questionList):
    print(i)
